<template>
	<el-form ref="form" :model="LoginForm" label-width="80px">
	  <el-form-item label="帐号">
	    <el-input v-model="LoginForm.username"></el-input>
	  </el-form-item>
	  
	  <el-form-item label="密码">
	    <el-input type='password' v-model="LoginForm.password"></el-input>
	  </el-form-item>
	  
	  <el-form-item>
	    <el-button type="primary" @click="login()">登录</el-button>
	    <el-button>取消</el-button>
	  </el-form-item>
	</el-form>
</template>

<script>
	export default{
		data() {
			return{
				LoginForm:{
					username:'admin',
					password:'123456'
				}
			}
		},
		
		created() {
			// this.login()
		},
		methods:{
			async login(){
				const {data:res} = await this.$ajax.post('http://api.io/api/Login/login',this.LoginForm)
				
				// console.log(res)
				//登录成功 提示 message组件
				if(res.code==1){
					this.$msg.success(res.msg)
					//存入session
					window.sessionStorage.setItem('token',res.token)
					//跳转后台
					this.$router.push('/')
				}else{
					this.$msg.error(res.msg)
				}
				
				
			}
		}
	}
</script>

<style>
</style>
